<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /*提前准备一个样式*/
        .Test1{
            color: yellowgreen;
            background: pink;
        }

        /*样式2*/
        .Test2{
            background-color: aqua;
        }
    </style>
</head>
<body>
    <div class = "Test1">测试内容1</div>
    <button class = "add-btn">追加样式类</button>
    <button class = "remove-btn">删除样式类</button>
    <button class = "toggle-btn">切换样式类</button>
    <script>
        var div = document.querySelector('div')
        var add_btn = document.querySelector('.add-btn')
        var remove_btn = document.querySelector('.remove-btn')
        var toggle_btn = document.querySelector('.toggle-btn')
        console.log(add_btn);
        console.log(remove_btn);
        add_btn.onclick = function(){
            div.classList.add('Test2')
        }

        remove_btn.onclick = function(){
            div.classList.remove('Test2');
        }

        toggle_btn.onclick = function(){
            div.classList.toggle('Test1');
        }
    </script>
</body>
</html>